﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Skybot
{
    /// <summary>
    /// 路径画线方法 
    /// </summary>
    public partial class PathCommon
    {

        /// <summary>
        /// 画一个二次倍赛尔曲线
        /// </summary>
        /// <param name="start">开始</param>
        /// <param name="controlPoint">控制点</param>
        /// <param name="end">结束点</param>
        /// <returns>返回值</returns>
        public static Path Draw(System.Windows.Point start, Point controlPoint, Point end)
        {
            return Draw(start, controlPoint, end, Colors.Red, 5);
        }
        /// <summary>
        /// 画一个二次倍赛尔曲线
        /// </summary>
        /// <param name="start">开始</param>
        /// <param name="controlPoint">控制点</param>
        /// <param name="end">结束点</param>
        /// <param name="width">宽度</param>
        /// <param name="color">颜色</param>
        /// <returns>返回值</returns>
        public static Path Draw(System.Windows.Point start, Point controlPoint, Point end, Color color, double width = 3.0)
        {
            Path path = new Path();
            //颜色填充
            path.Stroke = new SolidColorBrush(color);
            path.StrokeThickness = width;

            PathGeometry pathgeo = new PathGeometry();
            path.Data = pathgeo;
            PathFigureCollection coll = new PathFigureCollection();
            pathgeo.Figures = coll;
            //起点
            PathFigure figu = new PathFigure() { StartPoint = start };
            coll.Add(figu);


            QuadraticBezierSegment bezier = new QuadraticBezierSegment()
            {
                Point1 = controlPoint,
                Point2 = end
            };
            figu.Segments.Add(bezier);




            return path;

        }

    }
}
